package net.vanchu.mortgagecalculator.mortgage.calculate.single;

import net.vanchu.mortgagecalculator.common.config.LoanWay;

/**
 * 只要是 set 方法都检查是否合法
 * <p/>
 * Created by Granton on 2016/12/19.
 */
public class SingleLoanWayInputData {

    private LoanWay currentLoanWay = null;

    private int year = 0;

    private float value = 0;

    private float rate = 0;

    private float discount = 0;

    public LoanWay getCurrentLoanWay() {
        return currentLoanWay;
    }

    public void setCurrentLoanWay(LoanWay currentLoanWay) {
        this.currentLoanWay = currentLoanWay;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public float getValue() {
        return value;
    }

    public void setValue(float value) {
        this.value = value;
    }

    public float getRate() {
        return rate;
    }

    public void setRate(float rate) {
        this.rate = rate;
    }

    public float getDiscount() {
        return discount;
    }

    public void setDiscount(float discount) {
        this.discount = discount;
    }

    public boolean inputSatisfied() {
        if (currentLoanWay == null) {
            return false;
        }
        if (year == 0) {
            return false;
        }
        if (rate == 0) {
            return false;
        }
        if (discount == 0) {
            return false;
        }
        if (value == 0) {
            return false;
        }
        return true;
    }
}